package com.sdtv.mediunfusion.mvp.ui.outsidetask.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sdtv.mediunfusion.R;
import com.sdtv.mediunfusion.bean.AuditLoggingBean;

import java.util.List;

/**
 * @ProjectName: MediunFusion
 * @Package: com.sdtv.mediunfusion.mvp.ui.outsidetask.adapter
 * @ClassName: AudiLoggingAdapter
 * @Description: 报题-审核记录适配器
 * @Author: 小郭同学
 * @CreateDate: 2019-08-05 15:15
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class AudiLoggingAdapter extends BaseQuickAdapter<AuditLoggingBean, BaseViewHolder> {

    public AudiLoggingAdapter(int layoutResId, @Nullable List<AuditLoggingBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, AuditLoggingBean item) {
        helper.setText(R.id.logging_titleView, item.getAuditStatus())
                .setText(R.id.logging_timeView, item.getAuditTime())
                .setText(R.id.logging_personName, item.getAuditName());
        // 设置图标
        ImageView statusImg = helper.getView(R.id.logging_statusImg);
        int position = helper.getLayoutPosition();
        if (0 == position) {
            statusImg.setImageResource(R.mipmap.ic_songshen);
        } else {
            if ("通过".contains(item.getAuditStatus())) {
                statusImg.setImageResource(R.mipmap.ic_shenhetongguo);
            } else {
                statusImg.setImageResource(R.mipmap.ic_bohui);
            }
        }
        // 如果是最后一个 需要显示原因
        // 最后一个 去掉lineview ---只有最后一个才会有驳回原因
        if (position == getItemCount() - 1) {
            helper.setVisible(R.id.logging_lineView, false);
            //如果有驳回原因 需要显示
            if (!TextUtils.isEmpty(item.getRefuseReason())) {
                helper.setText(R.id.logging_lineView, "驳回原因：" + item.getRefuseReason())
                        .setVisible(R.id.logging_reason, true);
            }
        } else {
            helper.setVisible(R.id.logging_lineView, true)
                    .setVisible(R.id.logging_reason, false);

        }

    }


}
